package com.zkq.lvse.web.action;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.opensymphony.xwork2.ActionSupport;
import com.zkq.lvse.common.utils.Page;
import com.zkq.lvse.web.entity.User;
import com.zkq.lvse.web.service.UserService;

public class UserAction extends ActionSupport {

	/**
	 *  用户管理
	 */
	private static final long serialVersionUID = 1L;
	@Autowired
	private UserService userService;
	
	private Page<User> page=new Page<User>(10);
	private long pageNo;
	
	private User user=new User();
	private String id;
	private String username;
	private String password;
	private String sex;
	private int age;
	private String birthday;
	
	private List<User> list=new ArrayList<User>();
	
	public String list(){
		if(pageNo!=0&&!"".equals(pageNo)){
			page.setPageNo(pageNo);
		}
		page=userService.page(page);
		return "success";
	}
	public String delete(){
		if(id!=null&&!"".equals(id)){
			user=userService.get(id);
			userService.delete(user);
		}
		return "list";
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getSex() {
		return sex;
	}

	public void setSex(String sex) {
		this.sex = sex;
	}

	public int getAge() {
		return age;
	}

	public void setAge(int age) {
		this.age = age;
	}

	public String getBirthday() {
		return birthday;
	}

	public void setBirthday(String birthday) {
		this.birthday = birthday;
	}

	public List<User> getList() {
		return list;
	}

	public void setList(List<User> list) {
		this.list = list;
	}
	public Page<User> getPage() {
		return page;
	}
	public void setPage(Page<User> page) {
		this.page = page;
	}
	public long getPageNo() {
		return pageNo;
	}
	public void setPageNo(long pageNo) {
		this.pageNo = pageNo;
	}

}
